package lang

import (
	"go_gvm_mini/native"
	"go_gvm_mini/rtda"
	"go_gvm_mini/rtda/heap"
)

func init() {
	native.Registers("java/lang/String", []*native.NaMethod{
		{
			"intern",
			"()Ljava/lang/String;",
			intern,
		},
	})
}

// public native String intern();
func intern(jFrame *rtda.JFrame) {
	this := jFrame.LocalVars().GetThis()
	interned := heap.InterString(this)
	jFrame.OperandStack().PushRef(interned)
}
